import { moduleFor, test } from 'ember-qunit';

moduleFor('service:equal-svc', 'Unit | Service | equal svc', {
  // Specify the other units that are required for this test.
  // needs: ['service:foo']
});

// Replace this with your real tests.
test('recordEqual', function(assert) {
  var service = this.subject();
  assert.ok(service);

  assert.ok(service.recordEqual("1", 1), "number string");

  assert.ok(service.recordEqual({id: 1}, 1), "number objectnumber");
  assert.ok(service.recordEqual({id: "1"}, 1), "number objectstring");

  var o = {
    get: function(){
      return 1;
    }
  };
  assert.ok(service.recordEqual(o, 1), "number objectfunc");
});

test('arrayEqual', function(assert) {
  var service = this.subject();

  assert.ok(!service.arrayEqual("1", "1"), "not array");

  assert.ok(!service.arrayEqual(["1"], []), "different length");

  assert.ok(service.arrayEqual(["1"], ["1"]), "same length, same order.");

  assert.ok(service.arrayEqual([1, 2, 3], [1, 3, 2]), "same length, different order.");
  assert.ok(service.arrayEqual([1, "2", 3], [1, 3, "2"]), "same length, different type, different order.");
});

test('arraySort', (assert) => {
  var a = [{a:1}, {a:5}, {a:2}, {a:4},{a:7}];
  var b = a.sortBy('a');
  assert.equal(1, b[0].a);
  assert.equal(2, b[1].a);
});
